var viewEmailModel = new function () {
    this.TemplateId = ko.observable();
    this.Subject = ko.observable("").extend({ required: { message: "Tiêu đề là yêu cầu"} });
    this.FromEmail = ko.observable();
    this.CcEmail = ko.observable();
    this.BccEmail = ko.observable();
    this.Body = ko.observable();
    this.IsBodyHtml = ko.observable(false);
    this.Submit = function () {
        if (viewEmailModel.errors().length == 0) {
            $('form').submit();
        }
        this.errors.showAllMessages();
    }
}

viewEmailModel.errors = ko.validation.group(viewEmailModel);
ko.validation.rules.pattern.message = 'Invalid.';
ko.applyBindings(viewEmailModel, document.getElementById("main"));